import React,{ Component } from 'react';
import webData from './webData.json';  //导入json文件
import Navication from '../../demo/Navication/Navication.js';
import DemoInfo from './demoInfo.js';
export default class DemoCenter extends React.Component{
    constructor(){
        super();
        this.state = {
            webData : webData,
            DemoInfo: new DemoInfo,
        };
    	//添加demo信息
    	this.state.DemoInfo.adddemoItem({cId:"001",belongto:"01",DemoName:<Navication />});
    }
    render(){
    	let webData = this.state.webData.webName;
    	let href="";
    	let cId = this.props.cId;
    	let cBelongto = this.props.cBelongto;
    	let name = "";
    	let items = [];
    	let demoInfo = this.state.DemoInfo.demoinfo;
    	
    	webData.forEach(function(value, index, array) {
	    	value.children.forEach(function(value, index, array) {
	    		if(value.id==cId){
	    			href = value.ifmSrc;
	    		}else{
					if(value.belongto==cBelongto){
						name = value.name;
					}
				}
			});
		});
		demoInfo.forEach(function(value, index, array) {
			if(value.belongto == cBelongto){
				items.push(value.DemoName);
			}
		});	
		console.log(items);
        return (
			<div className="conDiv row">
				<div className="democontent">
					{items}
				</div>
				<div className="pageTurn">
					<span>相关Demo案例：</span>
					<a>{name}</a>
				</div>
				<div className="downLoad" ref="downLoad">
					<input ref="downBtn" className="downBtn" type="button" value="源码下载" />
				</div>
			</div>
        );
    }
}
